trigger new object creation

Hello all,

I have a fairly simple question (I think), how do I get a trigger to activate on the creation of a new object? I'm relatively new to triggers but well versed in DXL, and can get my code to run when I modify an attribute or save it but don’t know the proper syntax for creation. Any help would be appreciated, the line of code I tried is below but obviously it doesn’t work.

Trigger t = trigger("New Object Trigger", module->object, post, creation, 1, "include# </code.dxl>")
iannacones1 - Tue May 11 23:19:35 EDT 2010

Re: trigger new object creation
iannacones1 - Tue May 11 23:23:32 EDT 2010

also, I'm using DOORS 8.3 if that matters...

Re: trigger new object creation
johnzweck - Wed May 12 11:25:10 EDT 2010

Create triggers work only on discussions and comments. Use a sync trigger similar to:

trigger("New Object Trigger", module->object, post, sync, 10, "print identifier(current Object) \"\\n\"")

 


This actually looks at all objects, but you can put a check in your DXL file to see if it's a new Object. Using this as a post sync ensures that the current Object is the new Object.

John

 

Re: trigger new object creation
Mathias Mamsch - Wed May 12 11:30:26 EDT 2010

Hi iannacones,

I am not aware of a way to trigger on object creation. If you look at the "Trigger overview" table in the DXL help you will find that the only triggers for objects are open/sync, which will trigger on locking an object and changing the current object. Not sure, what you are trying to do, but if you find a solution for that a lot of people will be very interested. Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: trigger new object creation
iannacones1 - Wed May 12 12:28:56 EDT 2010

johnzweck - Wed May 12 11:25:10 EDT 2010

Create triggers work only on discussions and comments. Use a sync trigger similar to:

trigger("New Object Trigger", module->object, post, sync, 10, "print identifier(current Object) \"\\n\"")

 


This actually looks at all objects, but you can put a check in your DXL file to see if it's a new Object. Using this as a post sync ensures that the current Object is the new Object.

John

 

> johnzweck wrote:
> put a check in your DXL file to see if it's a new Object.

I had though that this maybe the way to go, any insight on the best way to identify if an object is new?

Re: trigger new object creation
iannacones1 - Wed May 12 15:32:31 EDT 2010

johnzweck - Wed May 12 11:25:10 EDT 2010

Create triggers work only on discussions and comments. Use a sync trigger similar to:

trigger("New Object Trigger", module->object, post, sync, 10, "print identifier(current Object) \"\\n\"")

 


This actually looks at all objects, but you can put a check in your DXL file to see if it's a new Object. Using this as a post sync ensures that the current Object is the new Object.

John

 

This is what i came up with...
 

Trigger T = current Trigger
Object o = object T
 
Date cr = o."Created On"
 
int curTime = intOf(dateAndTime(today)) //current time in seconds
int creTime = intOf(dateAndTime(cr))    //object creation time in seconds
 
creTime = creTime + 1 //increase object creation time by 1 sec
 
//if object was created in the last sec then...
if(curTime < creTime) then {
 /****** whatever code you want ******/
}

Re: trigger new object creation
Mathias Mamsch - Wed May 12 15:48:24 EDT 2010

johnzweck - Wed May 12 11:25:10 EDT 2010

Create triggers work only on discussions and comments. Use a sync trigger similar to:

trigger("New Object Trigger", module->object, post, sync, 10, "print identifier(current Object) \"\\n\"")

 


This actually looks at all objects, but you can put a check in your DXL file to see if it's a new Object. Using this as a post sync ensures that the current Object is the new Object.

John

 

When using a "sync" trigger you need to keep in mind, that it will not perform like a real "object creation" trigger.

a) Objects that are created by a DXL script will not fire the trigger (current object does not change)
b) The trigger might fire twice or more on a script action
c) Copying objects will not fire the trigger (current object does not change)
d) Creating Tables will fire the trigger only for the first cell
e) That check if the object was created at this second can get problematic! You will get glitches (second increased before trigger was executed).

For all these reasons and probably some more I would recommend not to use a sync trigger as a replace for one of the missing triggers (link creation, object creation, deletions, etc.) The sync trigger is just to unreliable ...

You should think about if you can achieve the goal you have (whatever that is) by some other means ...

Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: trigger new object creation
llandale - Thu May 13 15:22:04 EDT 2010

This is over my head, but perhaps we can modify the 'create' object functions by inserting our own in the user's Top context. Such code would look something like this:

Object createOriginal(Object obj)
{  return(create(obj))      // issue call to the original create
}    // end createOriginal()
Object create(Object obj)
{      // Enhanced, replaces original create
   Object oCreated = createOriginal(obj)
   if (null oCreated) return(oCreated)
        // now deal with the newly created object 'oCreated' as you see fit
 
   return(oCreated)
}   // end enhanced create(Object)


Sadly, there 9 'create' Object functions that all must be Enhanced.

And then there's the problem of copy-pasted objects, but perhaps they use these 'create' functions.

And then there's the problem of inserting this code into the User's top context. Perhaps that can be done with a post-module-open trigger, that cleverly uses eval_ to determine if function 'createOriginal' exists, and if not then issues evalTop_ to insert the code.

One should write this code as carefully as one would light a BBQ fire, while holding a leaky baggy of gasolene over your head.

Look forward to Mathias' input here. This is new territory. Perhaps he can become the 'Columbus of DXL Enhancement', ignoring contributions by previous Lief Ericsons.

 

 

  • Louie

 

 

Re: trigger new object creation
Mathias Mamsch - Thu May 13 15:52:37 EDT 2010

llandale - Thu May 13 15:22:04 EDT 2010

This is over my head, but perhaps we can modify the 'create' object functions by inserting our own in the user's Top context. Such code would look something like this:

Object createOriginal(Object obj)
{  return(create(obj))      // issue call to the original create
}    // end createOriginal()
Object create(Object obj)
{      // Enhanced, replaces original create
   Object oCreated = createOriginal(obj)
   if (null oCreated) return(oCreated)
        // now deal with the newly created object 'oCreated' as you see fit
 
   return(oCreated)
}   // end enhanced create(Object)


Sadly, there 9 'create' Object functions that all must be Enhanced.

And then there's the problem of copy-pasted objects, but perhaps they use these 'create' functions.

And then there's the problem of inserting this code into the User's top context. Perhaps that can be done with a post-module-open trigger, that cleverly uses eval_ to determine if function 'createOriginal' exists, and if not then issues evalTop_ to insert the code.

One should write this code as carefully as one would light a BBQ fire, while holding a leaky baggy of gasolene over your head.

Look forward to Mathias' input here. This is new territory. Perhaps he can become the 'Columbus of DXL Enhancement', ignoring contributions by previous Lief Ericsons.

 

 

  • Louie

 

 

Sorry Louie to disappoint you there, but I will not get on a boat for this one :-) Hooking create on the top level will do for all DXL scripts you could easily do that on the startup script of the client, but this has no effect on the module editor. The problem is that object creation by pressing "Insert" or Copy/Pasting objects is rooted deep in the DOORS client outside the scope of DXL. This gets obvious, when you think about the fact that copying an object will copy even attribute values that you have no access to (which is a great way of identifying copied objects by the way). Modifying the DOORS client to do this might be possible but is probably generally a bad idea.

What works decently is a "pre save" trigger on the module, that will scan for objects that have been created in this session (check the DOORS history!) and perform some action, maybe combined with the sync trigger that will fire only unreliably and remember the user to do stuff.

I find that people want to implement those "object creation" triggers because they want to fill out an attribute, present a dialog box to "force" the user to do something or some other reason. In 95% of the cases there is probably a more DOORS like way to do the same thing, but iannacones did not tell us what the reason for the object creation trigger is, so I cannot help with this one.

Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: trigger new object creation
Jagtattoo2 - Tue Apr 17 10:45:45 EDT 2018

Mathias Mamsch - Thu May 13 15:52:37 EDT 2010
Sorry Louie to disappoint you there, but I will not get on a boat for this one :-) Hooking create on the top level will do for all DXL scripts you could easily do that on the startup script of the client, but this has no effect on the module editor. The problem is that object creation by pressing "Insert" or Copy/Pasting objects is rooted deep in the DOORS client outside the scope of DXL. This gets obvious, when you think about the fact that copying an object will copy even attribute values that you have no access to (which is a great way of identifying copied objects by the way). Modifying the DOORS client to do this might be possible but is probably generally a bad idea.

What works decently is a "pre save" trigger on the module, that will scan for objects that have been created in this session (check the DOORS history!) and perform some action, maybe combined with the sync trigger that will fire only unreliably and remember the user to do stuff.

I find that people want to implement those "object creation" triggers because they want to fill out an attribute, present a dialog box to "force" the user to do something or some other reason. In 95% of the cases there is probably a more DOORS like way to do the same thing, but iannacones did not tell us what the reason for the object creation trigger is, so I cannot help with this one.

Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Hello, Mathias.

I've tried using the module close trigger as a way to check if newly created objects were created using the traditional methods (Ctrl-N, Ctrl-L, Insert->Object->Below, etc) or through our CPS Insert Pending Change function.  It somewhat worked, but was not optimal in that it would cause several objects to be "burned" if the creation was done outside of the CPS controls.  I was hoping for the object pre create trigger capability to implemented.  If there is no plan to implement this trigger event for objects, then I could try investigating other possibilities, or go back to the module close trigger function.

Thank you for all that you and others have done to keep these forums running and available.

Kind regards,

John